package com.har.modules.business.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.har.common.utils.PageUtils;
import com.har.common.utils.Query;
import com.har.modules.business.dao.TBaseProductDao;
import com.har.modules.business.entity.TBaseProductEntity;
import com.har.modules.business.service.TBaseProductService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("tBaseProductService")
public class TBaseProductServiceImpl extends ServiceImpl<TBaseProductDao, TBaseProductEntity> implements TBaseProductService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<TBaseProductEntity> page = this.selectPage(
                new Query<TBaseProductEntity>(params).getPage(),
                new EntityWrapper<TBaseProductEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public TBaseProductEntity getOneByProductType(Integer productType) {
        EntityWrapper<TBaseProductEntity> ew = new EntityWrapper<>();
        ew.eq("product_type",productType);
        TBaseProductEntity tBaseProductEntity = selectOne(ew);

        return  tBaseProductEntity;
    }
}
